/**
*
*  工具函数文件
*
*/

window.utils = {};
window.utils.ontouchtof = "ontouchend" in document?true:false;

// 解析色彩
window.utils.parseColor = function (color, toNumber) {
  if (toNumber === true) {
    if (typeof color === 'number') {
      return (color | 0); //chop off decimal
    }
    if (typeof color === 'string' && color[0] === '#') {
      color = color.slice(1);
    }
    return window.parseInt(color, 16);
  } else {
    if (typeof color === 'number') {
      color = '#' + ('00000' + (color | 0).toString(16)).substr(-6); //pad
    }
    return color;
  }
};

// 随机颜色
window.utils.getRandomColor = function(){

  return '#'+(Math.random()*0xffffff<<0).toString(16);

}